package com.halflife.nettyio;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.sql.SQLOutput;

public class GenerateStr {
    public static void main(String[] args) {
        String abc = "一";
        byte[] b1 = abc.getBytes(StandardCharsets.UTF_8);
        String xx = new String(b1, StandardCharsets.ISO_8859_1);
        String xx1 = new String(xx.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
        System.out.println(xx);
        System.out.println(xx1);
        System.out.println("================");
        printBytes(abc,StandardCharsets.ISO_8859_1);
        printBytes(abc,StandardCharsets.UTF_8);
    }

    public static void printBytes(String abc, Charset charset) {
        byte[] bytes = abc.getBytes(charset);
        System.out.println(charset.displayName());
        System.out.println(bytes.length);
        for (int i = 0; i < bytes.length; i++) {
            System.out.println(bytes[i]);
        }
        System.out.println(new String(bytes,charset));
        System.out.println(new String(bytes,StandardCharsets.UTF_8));
    }
}
